<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="FastFDS安装及使用, Python,HTML,CSS,JavaScript,Web安全等">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>FastFDS安装及使用 | 孤狼</title>
    <link rel="icon" type="image/png" href="/a.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
	<script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>

<meta name="generator" content="Hexo 5.4.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
			<div class="brand-logo">
				<a href="/" class="waves-effect waves-light">
					<div>
						
						<img src="/loading.gif" data-original="/medias/logo.png" class="logo-img" alt="LOGO">
						
						<span class="logo-span">孤狼</span>
					</div>
				</a>
			</div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">

      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/categories/linux">
          
          <span>linux</span>
        </a>
      </li>
      
      <li>
        <a href="/categories/python">
          
          <span>python</span>
        </a>
      </li>
      
      <li>
        <a href="/categories/%E5%8D%9A%E5%AE%A2">
          
          <span>博客</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/loading.gif" data-original="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">孤狼</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-bookmark"></i>
			
			分类
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>

                  <a href="/categories/linux " style="margin-left:75px">
				  
		          <span>linux</span>
                  </a>
                </li>
              
                <li>

                  <a href="/categories/python " style="margin-left:75px">
				  
		          <span>python</span>
                  </a>
                </li>
              
                <li>

                  <a href="/categories/%E5%8D%9A%E5%AE%A2 " style="margin-left:75px">
				  
		          <span>博客</span>
                  </a>
                </li>
              
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
    </ul>
</div>


        </div>

        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('请输入访问本文章的密码')).toString(CryptoJS.enc.Hex)) {
                alert('密码错误，将返回主页！');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/2.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">FastFDS安装及使用</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/linux/">
                                <span class="chip bg-color">linux</span>
                            </a>
                        
                            <a href="/tags/FastDFS/">
                                <span class="chip bg-color">FastDFS</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/linux/" class="post-category">
                                linux
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-04-01
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2.3k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    10 分
                </div>
                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h1 id="FastDFS安装及使用"><a href="#FastDFS安装及使用" class="headerlink" title="FastDFS安装及使用"></a>FastDFS安装及使用</h1><h2 id="1-FastDFS安装"><a href="#1-FastDFS安装" class="headerlink" title="1. FastDFS安装"></a>1. FastDFS安装</h2><p>包下载地址：<code>https://github.com/happyfish100</code></p>
<h3 id="1-1-安装前的准备"><a href="#1-1-安装前的准备" class="headerlink" title="1.1 安装前的准备"></a>1.1 安装前的准备</h3><ul>
<li><p>检查Linux上是否安装了gcc、libevent、libevent-devel</p>
<pre class=" language-shell"><code class="language-shell">yum list installed | grep gcc
yum list installed | grep libevent
yum list installed | grep libevent-devel
</code></pre>
</li>
<li><p>如果没有安装，则需进行安装</p>
<pre class=" language-shell"><code class="language-shell">yum install gcc libevent libevent-devel -y

yum install cmake make gcc-c++ -y
</code></pre>
</li>
<li><p>创建一个目录，把有关fdfs存储在一起</p>
<pre class=" language-shell"><code class="language-shell">mkdir -p /usr/local/fastdfs
</code></pre>
</li>
<li><p>进入目录，开始下载各种所需库并安装</p>
<pre class=" language-shell"><code class="language-shell">cd /usr/local/fastdfs
</code></pre>
<p>以下每一步操作都需要先回到该目录！！！</p>
</li>
</ul>
<h3 id="1-2-安装-libfastcommon库"><a href="#1-2-安装-libfastcommon库" class="headerlink" title="1.2 安装 libfastcommon库"></a>1.2 安装 libfastcommon库</h3><p>​    libfastcommon库是FastFDS文件系统运行所需要的公共C语言函数库</p>
<ul>
<li><p>首先拷贝libfastcommon库到linux上，或者直接下载</p>
<pre class=" language-shell"><code class="language-shell">wget https://github.com/happyfish100/libfastcommon/archive/V1.0.43.tar.gz
</code></pre>
</li>
<li><p>解压</p>
<pre class=" language-shell"><code class="language-shell">tar -zxvf libfastcommon-1.0.43.tar.gz
</code></pre>
</li>
<li><p>进入目录</p>
<pre class=" language-shell"><code class="language-shell">cd libfastcommon-1.0.43/
</code></pre>
</li>
<li><p>ls查看目录，然后编译</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost libfastcommon-1.0.43]# ls
doc  HISTORY  INSTALL  libfastcommon.spec  make.sh  php-fastcommon  README  src
[root@localhost libfastcommon-1.0.43]# ./make.sh
</code></pre>
</li>
<li><p>编译完成后进行安装</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost libfastcommon-1.0.43]# ./make.sh install
</code></pre>
<img src="/loading.gif" data-original="/posts/45952/%E6%A0%B8%E5%BF%83%E5%BA%93%E5%AE%89%E8%A3%85.png" class="" title="{核心库安装}"></li>
<li><p>因为FastFDS主程序设置的lib目录是/usr/local/lib，所以需要创建软链接</p>
<pre class=" language-shell"><code class="language-shell">ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
ln -s /usr/local/lib64/libfdfsclient.so /usr/local/lib/libfdfsclient.so
ln -s /usr/local/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
</code></pre>
</li>
</ul>
<h3 id="1-3-安装FastDFS"><a href="#1-3-安装FastDFS" class="headerlink" title="1.3 安装FastDFS"></a>1.3 安装FastDFS</h3><ul>
<li><p>下载FastDFS</p>
<pre class=" language-shell"><code class="language-shell">wget https://github.com/happyfish100/fastdfs/archive/V6.06.tar.gz
</code></pre>
</li>
<li><p>解压并进入目录</p>
<pre class=" language-shell"><code class="language-shell">tar -zxvf fastdfs-6.06.tar.gz && cd fastdfs-6.06
</code></pre>
</li>
<li><p>在单机模式(集群不建议更改)下可以更改下安装目录，比如更改到/usr/local；不更改跳过此步骤</p>
<pre class=" language-shell"><code class="language-shell">vim make.sh   # 进入编辑模式
/TARGET_PREFIX  # 查找TARGET_PREFIX，修改值为 /usr/local
</code></pre>
<img src="/loading.gif" data-original="/posts/45952/FastFDS%E5%AE%89%E8%A3%85%E6%9B%B4%E6%94%B9%E5%AE%89%E8%A3%85%E7%9B%AE%E5%BD%95.png" class="" title="{FastFDS安装更改安装目录}"></li>
<li><p>编译安装</p>
<pre class=" language-shell"><code class="language-shell">./make.sh && ./make.sh install
</code></pre>
<p>安装后，FastFDS主程序所在的位置是：</p>
<ul>
<li><code>/usr/local/bin</code>可执行文件(内置命令)所在位置。默认安装在<code>/usr/bin</code>中。</li>
<li><code>/etc/fdfs</code>配置文件所在位置。就是默认位置。</li>
<li><code>/usr/local/lib64</code>主程序代码所在位置。默认在<code>/usr/bin</code>中。</li>
<li><code>/usr/local/include/fastdfs</code>包含的一些插件组所在位置。默认在<code>/usr/include/fastdfs</code>中。</li>
<li><code>/etc/init.d</code>对应服务脚本所在位置。默认位置。</li>
</ul>
</li>
</ul>
<h2 id="2-FastDFS配置-amp-启动"><a href="#2-FastDFS配置-amp-启动" class="headerlink" title="2. FastDFS配置&amp;启动"></a>2. FastDFS配置&amp;启动</h2><blockquote>
<p><em><strong><font color="blue">tips：先启动tracker，最后启动storage！！！否则会启动失败</font></strong></em></p>
</blockquote>
<h3 id="2-1-配置tracker-amp-启动"><a href="#2-1-配置tracker-amp-启动" class="headerlink" title="2.1 配置tracker&amp;启动"></a>2.1 配置tracker&amp;启动</h3><ul>
<li><p>进入<code>/etc/fdfs</code>目录，使用模板创建tracker.conf文件</p>
<pre class=" language-shell"><code class="language-shell">cp tracker.conf.sample tracker.conf
</code></pre>
</li>
<li><p>使用vim修改tracker.conf文件</p>
<pre class=" language-shell"><code class="language-shell">base_path = /fastdfs/tracker  # 配置tracker存储数据的目录，默认在/home/yuqing/fastdfs，所以需要修改
</code></pre>
<p>修改完成后记得创建目录</p>
<pre class=" language-shell"><code class="language-shell">mkdir -p /fastdfs/tracker
</code></pre>
</li>
<li><p>启动tracker</p>
<pre class=" language-shell"><code class="language-shell"># 1.进入/etc/init.d/目录
cd /etc/init.d/

# 2.因为前面修改了安装位置，所以需要修改tracker配置文件的启动目录。没有修改安装位置跳过此步骤
vim fdfs_trackerd
# 修改RPG目录，把/usr/bin/改为/usr/local/bin/

# 3.启动tracker
[root@localhost init.d]# ./fdfs_trackerd start    # 启动tracker
Starting FastDFS tracker server: 
[root@localhost init.d]# ./fdfs_trackerd status   # 查看启动状态
fdfs_trackerd (pid 6637) is running...
[root@localhost init.d]# ps -ef | grep fdfs       # 验证启动状态
root       6637      1  0 14:48 ?        00:00:00 /usr/local/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root       6670   2427  0 14:49 pts/0    00:00:00 grep --color=auto fdfs
[root@localhost init.d]# 
</code></pre>
<img src="/loading.gif" data-original="/posts/45952/%E5%90%AF%E5%8A%A8tracker.png" class="" title="{启动tracker}"></li>
<li><p>设置开机启动</p>
<pre class=" language-shell"><code class="language-shell">vim /etc/rc.d/rc.local 
# 在末尾增加
/etc/init.d/fdfs_trackerd start
</code></pre>
<img src="/loading.gif" data-original="/posts/45952/%E8%AE%BE%E7%BD%AEtracker%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8.png" class="" title="{设置tracker开机启动}"></li>
</ul>
<h3 id="2-2-配置storage-amp-启动"><a href="#2-2-配置storage-amp-启动" class="headerlink" title="2.2 配置storage&amp;启动"></a>2.2 配置storage&amp;启动</h3><ul>
<li><p>进入<code>/etc/fdfs</code>目录，使用模板创建storage.conf文件</p>
<pre class=" language-shell"><code class="language-shell">cp storage.conf.sample storage.conf
</code></pre>
</li>
<li><p>使用vim修改storage.conf文件</p>
<pre class=" language-shell"><code class="language-shell">base_path=/fastdfs/storage/base #storage存储数据目录
store_path0=/fastdfs/storage/store #真正存放文件的目录
tracker_server=192.168.21.129:22122 #注册当前存储节点的跟踪器地址
</code></pre>
<p>修改完成后记得创建目录</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost fdfs]# mkdir -p /fastdfs/storage/base
[root@localhost fdfs]# mkdir -p /fastdfs/storage/store
</code></pre>
</li>
<li><p>启动storage</p>
<pre class=" language-shell"><code class="language-shell"># 1.进入/etc/init.d/目录
cd /etc/init.d/

# 2.因为前面修改了安装位置，所以需要修改tracker配置文件的启动目录。没有修改安装位置跳过此步骤
vim /etc/init.d/fdfs_storaged 
# 修改RPG目录，把/usr/bin/改为/usr/local/bin/

# 3.启动storage
[root@localhost fdfs]# /etc/init.d/fdfs_storaged start
Reloading systemd:                                         [  OK  ]
Starting fdfs_storaged (via systemctl):                    [  OK  ]
[root@localhost fdfs]# /etc/init.d/fdfs_storaged status
● fdfs_storaged.service - LSB: FastDFS storage server
   Loaded: loaded (/etc/rc.d/init.d/fdfs_storaged; bad; vendor preset: disabled)
   Active: active (exited) since Wed 2020-12-23 15:08:48 CST; 28s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 7124 ExecStart=/etc/rc.d/init.d/fdfs_storaged start (code=exited, status=0/SUCCESS)

Dec 23 15:08:48 localhost.localdomain systemd[1]: Starting LSB: FastDFS storage server...
Dec 23 15:08:48 localhost.localdomain fdfs_storaged[7124]: Starting FastDFS storage server:
Dec 23 15:08:48 localhost.localdomain systemd[1]: Started LSB: FastDFS storage server.
</code></pre>
</li>
</ul>
<h3 id="2-3-客户端配置-仅测试用，可以不进行此步骤而使用代码测试"><a href="#2-3-客户端配置-仅测试用，可以不进行此步骤而使用代码测试" class="headerlink" title="2.3 客户端配置(仅测试用，可以不进行此步骤而使用代码测试)"></a>2.3 客户端配置(仅测试用，可以不进行此步骤而使用代码测试)</h3><ul>
<li><p>同上进入<code>/etc/fdfs</code>目录，使用模板创建client.conf文件并修改配置</p>
<pre class=" language-shell"><code class="language-shell">cd /etc/fdfs
cp client.conf.sample client.conf
vim client.conf
mkdir -p /fastdfs/client

# client.conf  修改以下两个配置
base_path = /fastdfs/client    # 客户端产生的数据
tracker_server = 192.168.21.129:22122   # tracker的服务
</code></pre>
</li>
<li><p>上面执行完毕即可测试上传文件了</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost fdfs]# fdfs_upload_file /etc/fdfs/client.conf /a.jpg 
group1/M00/00/00/wKgVgV_i802ALMJ3AA4L-ymgAPA595.jpg

# 解释：
# fdfs_upload_file  是上传文件命令，在/etc/local/bin下，因为/etc/local/bin为环境变量，所以可以在任何地方进行调用
# /etc/fdfs/client.conf  是指定客户端的配置文件
# /a.jpg   是要上传的文件。我这里在根目录下有一个a.jpg文件
# 最后返回的结果证明上传成功。group1是配置文件的组名，M00是虚拟目录，剩余的是真实目录

# 前面在storage中配置了store_path0=/fastdfs/storage/store
# 所以文件真实所在位置为/fastdfs/storage/store/00/00/wKgVgV_i802ALMJ3AA4L-ymgAPA595.jpg
</code></pre>
</li>
<li><p>删除文件</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost fdfs]# fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgVgV_i802ALMJ3AA4L-ymgAPA595.jpg

# 解释同上
</code></pre>
</li>
</ul>
<h2 id="3-FastDFS与Nginx联合使用"><a href="#3-FastDFS与Nginx联合使用" class="headerlink" title="3. FastDFS与Nginx联合使用"></a>3. FastDFS与Nginx联合使用</h2><h3 id="3-1-安装FastDFS的nginx组件"><a href="#3-1-安装FastDFS的nginx组件" class="headerlink" title="3.1 安装FastDFS的nginx组件"></a>3.1 安装FastDFS的nginx组件</h3><ul>
<li><p>下载nginx组件</p>
<pre class=" language-shell"><code class="language-shell">wget https://github.com/happyfish100/fastdfs-nginx-module/archive/V1.22.tar.gz
</code></pre>
</li>
<li><p>解压文件并进入</p>
<pre class=" language-shell"><code class="language-shell">tar -zxvf fastdfs-nginx-module-1.22.tar.gz -C /usr/local/fastdfs && cd /usr/local/fastdfs/fastdfs-nginx-module-1.22
</code></pre>
</li>
<li><p>编辑配置文件</p>
<pre class=" language-shell"><code class="language-shell"># 1.进入文件目录后有两个文件一个src目录，进入src目录
cd src

# 2.进入fastdfs-nginx-module-1.22/src目录后编辑config文件
vim config

修改如下内容
# 因为改过安装目录，所以修改如下
CORE_INCS="$CORE_INCS /usr/local/include/fastdfs /usr/include/fastcommon/"
# 未修改安装目录，修改如下
CORE_INCS="$CORE_INCS /usr/include/fastdfs /usr/include/fastcommon/"
</code></pre>
<p>编辑完成后需要在nginx启动时加入这个插件，所以需要安装nginx</p>
</li>
</ul>
<h3 id="3-2-安装nginx"><a href="#3-2-安装nginx" class="headerlink" title="3.2 安装nginx"></a>3.2 安装nginx</h3><ul>
<li><p>首先安装nginx所需要的依赖</p>
<pre class=" language-shell"><code class="language-shell">yum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel –y
</code></pre>
</li>
<li><p>下载nginx</p>
<pre class=" language-shell"><code class="language-shell">wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz
</code></pre>
</li>
<li><p>解压</p>
<pre class=" language-shell"><code class="language-shell">tar -zxvf tengine-2.3.2.tar.gz
</code></pre>
</li>
<li><p>配置nginx安装信息</p>
<pre class=" language-shell"><code class="language-shell">cd /usr/local/fastdfs/tengine-2.3.2
mkdir -p /var/temp/nginx

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi \
--add-module=/usr/local/fastdfs/fastdfs-nginx-module-1.22/src
</code></pre>
<p><code>--add-module</code>必须定义，此配置信息是用于指定安装nginx时需要加载的模块，如果未指定，nginx安装过程不会加载<code>fastdfs-nginx-module</code>模块，后续功能无法实现</p>
<p><code>--prefix</code>是指定nginx安装路径</p>
</li>
<li><p>修改fastdfs-nginx-module配置文件</p>
<pre class=" language-shell"><code class="language-shell">cd /usr/local/fastdfs/fastdfs-nginx-module-1.22/src
cp mod_fastdfs.conf /etc/fdfs/
cd /etc/fdfs/
vim mod_fastdfs.conf
# 修改内容如下
base_path=/tmp
tracker_server=192.168.21.129:22122
url_have_group_name = true
store_path0=/fastdfs/storage/store
</code></pre>
</li>
<li><p>拷贝两个http配置的文件，用于网页http协议</p>
<pre class=" language-shell"><code class="language-shell">cp /usr/local/fastdfs/fastdfs-6.06/conf/http.conf /etc/fdfs/
cp /usr/local/fastdfs/fastdfs-6.06/conf/mime.types /etc/fdfs/
</code></pre>
</li>
<li><p>创建nginx启动需要的软连接</p>
<pre class=" language-shell"><code class="language-shell">ln -s /usr/local/lib64/libfdfsclient.so /usr/lib/libfdfsclient.so
</code></pre>
<p>nginx启动后，会在默认的/usr/lib64目录中查找需要的so文件。如果在安装FastDFS时，修改了make.sh文件中的TARGET_PREFIX参数，则必须创建此软连接</p>
</li>
<li><p>创建网络访问存储服务的软连接</p>
<pre class=" language-shell"><code class="language-shell">ln -s /fastdfs/storage/store/data/ /fastdfs/storage/store/data/M00
</code></pre>
<p>在上传文件到FastDFS后，FastDFS会返回group1/M00/00/00/xxxxxxx.xxx。其中<code>group1</code>是组名，在<code>mod_fastdfs.conf</code>配置文件中已配置了<code>url_have_group_name</code>，以保证URL解析正确。而其中的<code>M00</code>是FastDFS保存数据时使用的虚拟目录，需要将这个虚拟目录定位到真实数据目录上。</p>
</li>
<li><p>编辑nginx配置文件</p>
<pre class=" language-shell"><code class="language-shell">cd /usr/local/nginx  # 进入nginx目录
cd conf              # 进入nginx配置目录
vim nginx.conf
# 修改内容如下
user root;   # 第一行启用user配置，访问文件时使用root用户，实际工作中不这样使用
listen 8888; # 在http中server中，修改监听端口为8888，因为storage中http端口为8888
location ~/group[0-9]/M00&#123;
            ngx_fastdfs_module;
        &#125;
</code></pre>
</li>
<li><p>重启storage并启动nginx</p>
<pre class=" language-shell"><code class="language-shell">/etc/init.d/fdfs_storaged restart   # 重启storage
/usr/local/nginx/sbin/nginx    # 启动nginx
</code></pre>
</li>
<li><p>再次上传文件，然后在浏览器访问图片看是否能正常展示</p>
<pre class=" language-shell"><code class="language-shell">[root@localhost fdfs]# fdfs_upload_file /etc/fdfs/client.conf /a.jpg 
group1/M00/00/00/wKgVgV_jFVOABknvAA4L-ymgAPA308.jpg

在浏览器打开：http://192.168.21.129:8888/group1/M00/00/00/wKgVgV_jFVOABknvAA4L-ymgAPA308.jpg，访问图片成功即部署成功。
</code></pre>
</li>
</ul>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">aze</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://alinze.gitee.io/posts/45952.html">https://alinze.gitee.io/posts/45952.html</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">aze</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/linux/">
                                    <span class="chip bg-color">linux</span>
                                </a>
                            
                                <a href="/tags/FastDFS/">
                                    <span class="chip bg-color">FastDFS</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/loading.gif" data-original="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/loading.gif" data-original="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/posts/27377.html">
                    <div class="card-image">
                        
                        
                        <img src="/loading.gif" data-original="/medias/featureimages/16.jpg" class="responsive-img" alt="协程及在爬虫中应用">
                        
                        <span class="card-title">协程及在爬虫中应用</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-04-09
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/python/" class="post-category">
                                    python
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/python/">
                        <span class="chip bg-color">python</span>
                    </a>
                    
                    <a href="/tags/%E5%BC%82%E6%AD%A5%E7%BC%96%E7%A8%8B/">
                        <span class="chip bg-color">异步编程</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/posts/13455.html">
                    <div class="card-image">
                        
                        
                        <img src="/loading.gif" data-original="/medias/featureimages/0.jpg" class="responsive-img" alt="文章Front-matter介绍">
                        
                        <span class="card-title">文章Front-matter介绍</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-03-31
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E5%8D%9A%E5%AE%A2/" class="post-category">
                                    博客
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E5%8D%9A%E5%AE%A2/">
                        <span class="chip bg-color">博客</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="355992"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2021-2022</span>
            
            <span id="year">2021</span>
            <a href="/about" target="_blank">aze</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
			 
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
             
             
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
             
            <br>
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2021";
                    var startMonth = "3";
                    var startDate = "14";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">


    <a href="https://gitee.com/alinze" class="tooltipped" target="_blank" data-tooltip="访问我的Gitee" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1124302640@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1124302640" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1124302640" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="https://www.cnblogs.com/L521Z" class="tooltipped" target="_blank" data-tooltip="关注我的博客园: https://www.cnblogs.com/L521Z" data-position="top" data-delay="50">
        <i class="fab fa-juejin">博</i>
    </a>



</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    


	
	<!--浏览器搞笑标题  自定义添加  -->
	<script type="text/javascript">
		var OriginTitile=document.title,st;
		document.addEventListener("visibilitychange",function(){
			document.hidden?(document.title="ヽ(●-`Д´-)ノ你要玩捉迷藏嘛",clearTimeout(st)):(document.title="(Ő∀Ő3)ノ好哦！",st=setTimeout(function(){document.title=OriginTitile},3e3))
		})
	</script>
	<!--动态线条背景-->
	<script type="text/javascript"
		color="122 103 238" opacity='0.7' zIndex="-2" count="200" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js">
	</script>
	<!--樱花飘落效果 themes/matery/source/js/sakura.js-->
	<script type="text/javascript">
	//只在桌面版网页启用特效
	var windowWidth = $(window).width();
	if (windowWidth > 768) {
		document.write('<script type="text/javascript" src="/js/sakura.js"><\/script>');
	}
	</script>

<script>
            window.imageLazyLoadSetting = {
                isSPA: false,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(n){n.imageLazyLoadSetting.processImages=i;var e=n.imageLazyLoadSetting.isSPA,r=(n.imageLazyLoadSetting.preloadRatio,Array.prototype.slice.call(document.querySelectorAll("img[data-original]")));function i(){e&&(r=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")));for(var t,a=0;a<r.length;a++)0<=(t=(t=r[a]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(n.innerHeight+240||document.documentElement.clientHeight+240)&&function(){var t,e,n,i,o=r[a];t=o,e=function(){r=r.filter(function(t){return o!==t})},n=new Image,i=t.getAttribute("data-original"),n.onload=function(){t.src=i,e&&e()},t.src!==i&&(n.src=i)}()}i(),n.addEventListener("scroll",function(){var t,e;t=i,e=n,clearTimeout(t.tId),t.tId=setTimeout(function(){t.call(e)},500)})}(this);</script><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/haruto.model.json"},"display":{"position":"right","width":150,"height":300,"hOffset":20,"vOffset":-30},"mobile":{"show":true,"scale":0.5},"react":{"opacityDefault":0.7,"opacityOnHover":0.2},"log":false});</script></body>

</html>
